package com.hondee.fuzzyquery.query;

import java.util.concurrent.CountDownLatch;

import com.hondee.fuzzyquery.entity.EntityCollections;
import com.hondee.fuzzyquery.entity.access.IEntityAccess;

public class QueryRunner implements Runnable {
	
	private IEntityAccess entityAccess;
	
	private EntityCollections collections;
	
	private CountDownLatch countDownLatch;
	
	public QueryRunner(IEntityAccess entityAccess,EntityCollections collections,CountDownLatch countDownLatch){
		this.entityAccess = entityAccess;
		this.collections = collections;
		this.countDownLatch = countDownLatch;
	}

	@Override
	public void run() {
		try{
			collections.put(entityAccess.access());
		}finally{
			countDownLatch.countDown();
		}
	}
}
